<%@ page import="com.entity.Page" %><%--
  Created by IntelliJ IDEA.
  User: jiangcuizhi
  Date: 2023/12/6
  Time: 10:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<link rel="stylesheet" href="${ctx}/public/css/adminMessage.css" media="all">
<link rel="stylesheet" href="${ctx}/public/css/bootstrap.css" media="all">
<link rel="stylesheet" href="${ctx}/public/css/popup.css" media="all">
<script type="text/javascript" src="${ctx}/js/jquery-3.6.1.js"></script>
<head>
    <title>Title</title>
</head>
<style>
    select{
        width: 200px;
        height: 40px;
        float: left;
        margin: 18px 15px;
        border-radius: 10px;
        border:1px solid rgb(220,223,230);
    }
</style>
<body>
<div class="content">
    <form method="post" action="${ctx}/adminSearch" class="one">
        <input type="text" placeholder="用户名" name="name" value="${name}"/>
        <strong style="margin-top: 30px;float: left">OR</strong>
        <select id="adminCondition" name="typeOrAuthor">
            <option value="">请选择用户类型</option>
            <option value="读者" <c:if test="${typeOrAuthor=='读者'}">selected</c:if>>读者</option>
            <option value="系统管理员" <c:if test="${typeOrAuthor=='系统管理员'}">selected</c:if>>系统管理员</option>
            <option value="图书管理员" <c:if test="${typeOrAuthor=='图书管理员'}">selected</c:if>>图书管理员</option>
        </select>
        <select id="adminConditionSort" name="conditionSort" lay-verify="required">
            <option value="ASC" <c:if test="${conditionSort=='ASC'}">selected</c:if>>升序</option>
            <option value="DESC" <c:if test="${conditionSort=='DESC'}">selected</c:if>>降序</option>
        </select>
        <button type="submit" style="background-color: rgb(64, 158, 255);margin: 23px;color: black">搜索</button>
        <button class="cleanLimit" type="submit" style="background-color: rgb(64, 158, 255);margin: 23px;color: black">ALL</button>
    </form>

    <ul style="margin-bottom: 0">
        <li>用户ID</li>
        <li>用户名</li>
        <li>密码</li>
        <li>生日</li>
        <li>性别</li>
        <li>用户类型</li>
        <li>账号状态</li>
        <li>欠费金额</li>
        <li>操作</li>
    </ul>
    <!-- 数据 -->

    <div class="data-box">
    <c:forEach items="${p.data}" var="admin">
        <ul class="model" style="margin-bottom: 0">
            <li>${admin.userid}</li>
            <li>${admin.username}</li>
            <li>${admin.pwdHash}</li>
            <li>${admin.birthday}</li>
            <li>${admin.sex}</li>
            <c:choose>
                <c:when test="${admin.usertype==1}"><li>读者</li></c:when>
                <c:when test="${admin.usertype==2}"><li>图书管理员</li></c:when>
                <c:when test="${admin.usertype==3}"><li>系统管理员</li></c:when>
            </c:choose>
            <li>${admin.isfull}</li>
            <li>${admin.money}</li>
            <li>
                <button style="height: 40px;" onclick="location.href='${ctx}/updataAdmin?user=${admin.username}&gender=${admin.sex}&pwd=${admin.pwdHash}&birthdayu=${admin.birthday}&type=${admin.usertype}'"><h4 style="text-align: center">更新</h4></button>
                <c:choose>
                    <c:when test="${admin.username==sessionName}">
                        <button style="height: 40px;background-color:#d2d2d2"><h4 style="color: #9a3333">禁删</h4></button>
                    </c:when>
                    <c:when test="${admin.username!=requset.getSession().getAttribute('username')}">
                        <button style="height: 40px;" onclick='location.href="${ctx}/deleteAdmin?userid=${admin.userid}&pageNumber=${p.pageNumber}&name=${param.name}&typeOrAuthor=${param.typeOrAuthor}&conditionSort=${param.conditionSort}"'><h4 style="text-align: center">删除</h4></button>
                    </c:when>
                </c:choose>
            </li>
        </ul>
    </c:forEach>
    </div>
    <jsp:include page="page.jsp">
        <jsp:param name="url" value="${ctx}/adminSearch"></jsp:param>
        <jsp:param name="name" value="${name}"/>
        <jsp:param name="typeOrAuthor" value="${typeOrAuthor}"/>
        <jsp:param name="conditionSort" value="${conditionSort}"/>
    </jsp:include>
</div>
<script>
    document.querySelector('.cleanLimit').addEventListener('click', function() {
        document.getElementsByName('name')[0].value = '';
        document.getElementById("adminCondition")[0].selected=true;
        document.getElementById("adminConditionSort")[0].selected=true;
        this.form.submit();
    });
</script>
</body>
</html>
